
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../../global/css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./frm.css" />
</head>
<body>
    <div id="switch-bar" class="aui-card-list-content">
        <div class="aui-tab" id="card-tab">
            <div class="aui-tab-item aui-active"><span>原创</span></div>
            <div class="aui-tab-item auix-nonactive"><span>复制文本</span></div>
            <div class="aui-tab-item auix-nonactive"><span>复制链接</span></div>
        </div>
    </div>

	<section id="main-body" class="auix-solo">
		<div id="original-editor" class="auix-solo-item">
            
            <div>
                <div class="">
                    <p class="top-tips aui-text-center"><img src="../../../global/image/red-light.png"/>内容越丰富，看的人越多赚的越多哦~</p>
                    <p id="top-ro-subject" class="aui-hide" tapmode onclick="ed1_onEditSubject(this);"></p>
                </div>

                <div id="original-content-frame">
                    <div id="original-select-media-top" class="aui-list"></div>

                    <div id="original-content" class="aui-list aui-form-list">
                        <!-- 描述/media/正文，插入在此div中 -->
                        <div id="original-content-inner"></div>

                        <div id="original-main-text"></div>
                    </div>

                    <div id="original-select-media-bottom" class="aui-list"></div>
                </div>

                <div id="subject-frame" class="aui-hide">
                    <p class="aui-text-center">填写完标题就能发布啦！看的人更多哦(至少2个字)</p>
                    <textarea id="subject" class="content" onblur="ed1_onSubjectBlur(this);" tapmode autofocus oninput="ed1_onInputSubject(this);" placeholder="输入标题..."></textarea>
                </div>
            </div>

            <script id="tpl-ed1-select-media" type="text/x-dot-template">
                <div class="aui-list-item-center">
                    <div class="select-media-frame aui-list-item-inner">
                        <div class="select-media-inner" tapmode onclick="ed1_onSelectMedia(this);">
                            <img class="select-media" src="../../../global/image/camera.png" />
                            <p>添加图片或视频</p>
                        </div>
                    </div>
                </div>
            </script>

            <script id="tpl-ed1-main-text" type="text/x-dot-template">
                <!-- 此处给 -1，是为了在形式上跟正文保持一致，以简化草稿流程代码 -->
                <div data-idx="-1" class="aui-list-item">
                    <div data-content="main-text" class="aui-list-item-inner">
                        <div class="aui-list-item-input">
                            <textarea class="content" onfocus="ed1_onMainFocus(this);" onblur="ed1_onMainBlur(this);" tapmode oninput="ed1_onMainInput(this);" placeholder=""></textarea>
                        </div>
                    </div>
                </div>
            </script>

            <script id="tpl-ed1-media-desc" type="text/x-dot-template">
                
                    <div data-idx="{{=it.idx}}" class="aui-list-item">
                        <div data-content="media-desc" class="aui-list-item-inner">
                			<div class="delete-btn" tapmode onclick="ed1_onDelete(this);"><i></i></div>
                            <div class="aui-list-item-input">
                                <textarea class="content" tapmode oninput="ed1_onInputMediaDesc(this);" placeholder="{{=it.ph}}"></textarea>
                            </div>
                        </div>
                    </div>

            </script>

            <script id="tpl-ed1-media-group" type="text/x-dot-template">
                <div data-idx="{{=it.idx}}" class="media-group">
                    
                        <div data-idx="{{=it.idx}}" class="aui-list-item">
                            <div data-content="media-desc" class="aui-list-item-inner">
                    			<div class="delete-btn" tapmode onclick="ed1_onDelete(this);"><i></i></div>
                                <div class="aui-list-item-input">
                                    <textarea class="content" tapmode oninput="ed1_onInputMediaDesc(this);" placeholder="{{=it.ph}}"></textarea>
                                </div>
                            </div>
                        </div>


                    <div data-idx="{{=it.idx}}" class="aui-list-item auix-adjust">
                        <div data-content="media" class="aui-list-item-inner">
                			<div class="delete-btn" tapmode onclick="ed1_onDelete(this);"><i></i></div>
                            {{? it.bImg }}
                                <!-- 图片: 发布时才上传到七牛，故此处的url为本地路径 -->
                                <img data-media="{{=it.mediaType}}" data-url="{{=it.url}}" src="{{=it.viewUrl}}" tapmode onclick="ed1_browseImages(this);" />
                            {{??}}
                                <!-- 视频: 已率先上传到七牛(因为我们在本地不能获取缩率图)，故url为远端地址，path为本地路径 -->
                                <div class="video-frame">
                                    <img data-media="{{=it.mediaType}}" data-path="{{=it.path}}" data-url="{{=it.url}}" src="{{=it.viewUrl}}" />
                                    <i class="time">{{=ms2VTime(it.duration)}}</i>
                                    <div class="play-video" tapmode onclick="ed1_playVideo(this);"><div class="op-btn"></div></div>
                                </div>
                            {{?}}
                        </div>
                    </div>
                    <div data-idx="{{=it.idx}}" class="aui-list-item">
                        <div data-content="media-body" class="aui-list-item-inner">
                			<div class="delete-btn" tapmode onclick="ed1_onDelete(this);"><i></i></div>
                            <div class="aui-list-item-input">
                                <textarea class="content" tapmode oninput="ed1_onInputMediaBody(this);" placeholder="您还可以输入正文"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </script>

		</div>
        <div id="paste-editor" class="auix-solo-item aui-hide">
            
            <p>粘贴</p>

        </div>
        <div id="import-editor" class="auix-solo-item aui-hide">
            
            <p>粘贴链接</p>

        </div>
	</section>
</body>

<script type="text/javascript" src="../../../config.js"></script>
<script type="text/javascript" src="../../../global/script/lib/api.js"></script>
<script type="text/javascript" src="../../../global/script/lib/aui-tab.js"></script>
<script type="text/javascript" src="../../../global/script/lib/doT.min.js"></script>
<script type="text/javascript" src="../../../global/script/libx/auix-solo.js"></script>
<script type="text/javascript" src="../../../global/script/libx/myPic.js"></script>
<script type="text/javascript" src="../../../global/script/libx/myAlbumBrowser.js"></script>
<script type="text/javascript" src="../../../global/script/libx/myCompact.js"></script>
<script type="text/javascript" src="../../../global/script/comp/oneMediaUploader.js"></script>
<script type="text/javascript" src="../../../global/script/mylib.js"></script>

<script type="text/javascript" src="../../../app.js"></script>

<script type="text/javascript" src="./editors/ed1_original.js"></script>
<script type="text/javascript" src="./editors/ed2_paste.js"></script>
<script type="text/javascript" src="./editors/ed3_import.js"></script>
<script type="text/javascript" src="./draftSaver.js"></script>

<script type="text/javascript" src="./frm.js"></script>

</html>

<script type="text/javascript" src="../../../global/script/_fakeApi.js"></script>

<script>
	apiready();

    // fooAddSubject();
    // fooAppendMedia();

    // window.curEditor.tryPubPost();

    function fooAddSubject() {
        $api.byId('subject').value = '这是标题';
    }

    function fooAppendMedia() {
        window.curEditor.appendMedia({
            url: '../../../global/image/river.jpg'
        }, 'image');
        // window.curEditor.appendMedia({
        //     url: '../../../global/image/girl.jpg',
        //     duration: 60000 // 单位 ms
        // }, 'video');
    }

    function fooSaveDraft() {
        var draft = window.curEditor.getDraft();
        localStorage.setItem('foo-draft', asJson(draft));
    }

    function fooRenderWithDraft() {
        var item = localStorage.getItem('foo-draft');
        if (item) {
            window.curEditor.renderWithDraft(toObj(item));
        }
    }

    function fooDumpPostBody() {
        var cont = window.curEditor._collectContentFromDom();
        tlog(asJson(cont));
        tlog("----------");
        var body = window.curEditor._makePostBody(cont);
        tlog(asJson(body));
    }

</script>
